#include<iostream>
using namespace std;
char arr[50][50];
int flag[50][50];
int next_1[4][2] = { {0,1},{1,0},{-1,0},{0,-1} };
int sum;
int n, m;

bool check(int x, int y)
{
	if (x >= 0 && x < n && y >= 0 && y < m) {
		return 1;
	}
	return 0;
}
void DFS(int x, int y)
{
	int tx, ty;
	int i = 0;
	for (i = 0; i < 4; i++) {
		tx = x + next_1[i][0];
		ty = y + next_1[i][1];
		if (check(tx, ty)) {
			if (arr[tx][ty] == '.' && flag[tx][ty] == 0) {
				flag[tx][ty] = 1;
				sum++;
				DFS(tx, ty);
			}
		}
	}
}
int main()
{
	cin >> n >> m;
	int x = 0, y = 0;
	int i, j;
	getchar();
	for (i = 0; i < n; i++) {
		for ( j = 0; j < m; j++) {
			cin >> arr[i][j];
			if (arr[i][j] == '@') {
				x = i;
				y = j;
				flag[x][y] = 1;
			}
		}
		getchar();
	}
	sum = 1;
	DFS(x, y);
	cout << sum << endl;
	return 0;
}